package com.javasm.service.MisMannageService.impl;


import com.javasm.dao.MisMannageDao.SeriesDao;
import com.javasm.dao.MisMannageDao.TypeDao;
import com.javasm.dao.MisMannageDao.impl.SeriesDaoImpl;
import com.javasm.dao.MisMannageDao.impl.TypeDaoImpl;
import com.javasm.entity.MisMannageEntity.ProdSeriesInfo;
import com.javasm.service.MisMannageService.AreaService;
import com.javasm.service.MisMannageService.SeriesService;

import java.util.List;

/**
 * @author:JAVASM
 * @description:
 * @date:2022/5/22 19:52
 * @version:0.1
 * @since:jdk11
 */
public class SeriesServiceImpl implements SeriesService {

    @Override
    public String getCompanyById(Integer seriesId) {
        return new SeriesDaoImpl().getCompanyById(seriesId);
    }

    @Override
    public List<ProdSeriesInfo> getSeriesName() {
        return new SeriesDaoImpl().getSeriesName();
    }

    @Override
    public Integer editProdSeries(ProdSeriesInfo editPsi) {
        return new SeriesDaoImpl().editProdSeries(editPsi);
    }

    @Override
    public ProdSeriesInfo queryProdSeriesById(Integer queryProdSeriesId) {
        SeriesDao sd = new SeriesDaoImpl();
        ProdSeriesInfo queryPsi = sd.queryProdSeriesById(queryProdSeriesId);
        TypeDao td = new TypeDaoImpl();
        Integer typeId = td.getTypeId(queryPsi.getSecondTypeName());
        queryPsi.setTypeId(typeId);
        return queryPsi;
    }

    @Override
    public Integer insertRemitMsg(ProdSeriesInfo addRemitMsgPsi, Integer addSeriesId) {
        AreaService as = new AreaServiceImpl();

        String bankAddr = addRemitMsgPsi.getBankAddr();
        String bankCity = addRemitMsgPsi.getBankCity();
        Integer bankAddrId = -1;
        if (bankAddr!=null && !"".equals(bankAddr)){
            bankAddrId = Integer.parseInt(bankAddr);
        }
        Integer bankCityId = -1;
        if (bankCity!=null && !"".equals(bankCity)){
            bankCityId = Integer.parseInt(bankCity);
        }

        String addrName = as.getAreaName(bankAddrId);
        String cityName = as.getAreaName(bankCityId);

        addRemitMsgPsi.setBankAddr(addrName);
        addRemitMsgPsi.setBankCity(cityName);
        return new SeriesDaoImpl().insertRemitMsg(addRemitMsgPsi,addSeriesId);
    }

    @Override
    public Integer insertProdSeries(ProdSeriesInfo addPsi) {
        return new SeriesDaoImpl().insertProdSeries(addPsi);
    }

    @Override
    public Integer seriesTotalNum(String querySeriesName) {
        return new SeriesDaoImpl().seriesTotalNum(querySeriesName);
    }

    @Override
    public List<ProdSeriesInfo> getSeriesByPage(Integer page, Integer pageSize, String querySeriesName) {
        return new SeriesDaoImpl().getSeriesByPage(page, pageSize, querySeriesName);
    }
}
